﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mrsoft.Common;


namespace Mrsoft.Core
{
    /// <summary>
    /// 答题发送的结果返回
    /// </summary>
    public class DatiResult
    {
        public DatiResult(bool ok, string message) {
            this.OK = ok;
            this.Message = message;
        }
        /// <summary>
        /// 是否发送成功
        /// </summary>
        public bool OK { private set; get; }

        /// <summary>
        /// 发送成功返回用于查询答案的
        /// </summary>
        public string Message { private set; get; }
    }

    public class DatiModel
    {
        /// <summary>
        /// 问题分类ID
        /// </summary>
        public int QuestinType { set; get; }
        /// <summary>
        /// 答题图片的全路径
        /// </summary>
        public string ImageFullPath { set; get; }
        /// <summary>
        /// 发送给答题方的提示信息
        /// </summary>
        public string TipsMessage { set; get; }
        /// <summary>
        /// 超时时间
        /// </summary>
        public int Timeout { set; get; }
    }

    public static class DatiManager
    {

        internal static Config<string> DatiSeviceHost = new Config<string>("./common.cfg", "Dati/SeverHost", "localhost");
        public static bool HuiYanDati { set; get; }
        public static IDati HuiYanDatiService { private set; get; }
        public static bool LocalDati { set; get; }
        public static IDati LocalDatiService { set; get; }

        public static DatiResult Answer(DatiModel datiModel) {

            if (HuiYanDati) {
                return HuiYanDatiService.Answer(datiModel);
            }
            if (LocalDati) {
                return LocalDatiService.Answer(datiModel);
            }

            return new DatiResult(false, "答题服务不可用状态！");
        }

        public static void Start() {
            HuiYanDatiService = new HuiYan();
        }
    }
}
